<?php



include '../include/init.php';

$method=$_POST['m'];


$th=new themeModel();

if($method=="get")
{
	$uid=$_POST['u'];

	$uth=$th->getUsertheme($uid);
	if($uth)
	{
		echo json_encode($uth);
	}
	else
	{
		echo json_encode(false);
	}
	exit;
}
else if($method=="getall")
{
	$list=$th->getThemes(17);
	if($list)
	{
		echo json_encode($list);
		exit;
	}
	echo json_encode(false);
	exit;
}
else if($method=="getscene")
{
	$list=array();

	$list['recommend']=$th->getreScene(4);
	$list['hot']=$th->gethotScene(4);
	echo json_encode($list);
	exit;

}
else if($method=="getbubble")
{
	$rs=$th->getbubbles(24);
	if($rs)
	{
		echo json_encode($rs);
		exit;
	}
	echo json_encode(false);
	exit;
}
else if($method=="setskin")
{
	$themeid=$_POST['t'];
	$uid=$_POST['u'];
	
	
	$theme=$th->getTheme($themeid);
	
	//检查是否会员
	if($theme['vip']==1)
	{
		$user=new userModel();
		if(!$user->isvip($uid))
		{
			echo json_encode('novip');
			exit;
		}
	}
	
	if($th->setTheme($uid,$themeid))
	{
		echo json_encode(true);
		exit;
	}

	echo json_encode(false);
	exit;

}
else if($method=="setcolor")
{
	$data=array();
	$data['bgcolor']=$_POST['c'];
	$data['bgimg']="";
	$data['skinopacity']=100;
	$data['glassopacity']=100;
	$uid=$_POST['u'];
	
	if($th->setUsertheme($uid,$data))
	{
		echo json_encode(true);
		exit;
	}

	echo json_encode(false);
	exit;

}
else if($method=="setpro")
{
	$uid=$_POST['u'];

	$data = str_replace(array(':',','),array('"=>"','","'),'array("'.$_POST['d'].'")');
	eval("\$data"." = $data;");
	//var_dump($data);
	if($th->setUsertheme($uid,$data))
	{
		echo json_encode(true);
		exit;
	}

	echo json_encode(false);
	exit;

}